<template>
  <div>

    <Search :search="search" :reset="reset">
      <template v-slot:body>
        <el-form-item label="单据编码" prop="docno">
          <el-input v-model="query.docno" name="docno" clearable />
        </el-form-item>
      </template>
    </Search>
    <div class="table-default">
      <!-- <Operate :show="open" /> -->
      <el-table :data="tableData" class="mt-3" v-loading="loading" border>
        
        <el-table-column label="单据编号" prop="docno" width="250"/>
        <!-- <el-table-column label="领料单号" prop="pick_order_no" width="250"/> -->
        <el-table-column label="创建者" prop="creator"/>
        <el-table-column label="创建时间" prop="created_at" />
        <el-table-column label="更新时间" prop="updated_at" />
        <!-- <el-table-column label="单据状态" prop="doc_status" ></el-table-column> -->
        <el-table-column label="操作" width="100">
          <template #default="scope">
            <router-link :to="{ path: '/production/materialReturnPlanDetail', query: { id: `${scope.row.id}` } }">
              <Show />
            </router-link>
            <!-- <Update @click="open(scope.row.id)" />
            <Destroy @click="destroy(api, scope.row.id)" /> -->
          </template>
        </el-table-column>
      </el-table>
      <Paginate />
    </div>

    <Dialog v-model="visible" :title="title" destroy-on-close>
      <Create @close="close(reset)" :primary="id" :api="api" />
    </Dialog>
  </div>
</template>

<script lang="ts" setup>
import { computed, onMounted } from 'vue'
import Create from './create.vue'
import { useGetList } from '/admin/composables/curd/useGetList'
import { useDestroy } from '/admin/composables/curd/useDestroy'
import { useOpen } from '/admin/composables/curd/useOpen'
import {setTableHeight} from '/admin/utils/setHeight.js'

const api = 'production/return/plan'

const { data, query, search, reset, loading } = useGetList(api)
const { destroy, deleted } = useDestroy()
const { open, close, title, visible, id } = useOpen()

const tableData = computed(() => data.value?.data)

onMounted(() => {
  search()
  deleted(reset)
  setTableHeight('.table-default')

})
</script>

<style lang="css">
.el-table {
  height: 80%;
}
</style>
